package apiday01.string;

/**
 * String 是不变对象 不适合频繁修改内容，开销大、性能差
 * StringBuilder 可变对像 适合频繁修改内容，开销小、性能好
 */
public class StringAndStringBuilderDemo {
    public static void main(String[] args) {
        //瞬间执行完毕
        StringBuilder builder = new StringBuilder("a");
        for (int i = 0; i < 1000000; i++) {
            builder.append("a");
        }

        //5min多执行结束
//        String str = "a";
//        for (int i = 0; i < 1000000; i++) {
//            str = str + "a";
//        }
        System.out.println("执行完毕");
    }
}
